import { uniqueId } from 'lodash'

/**
 * @description 给菜单数据补充上 path 字段
 * @description https://github.com/d2-projects/d2-admin/issues/209
 * @param {Array} menu 原始的菜单数据
 */
function supplementPath (menu) {
  return menu.map(e => ({
    ...e,
    path: e.path || uniqueId('d2-menu-empty-'),
    ...e.children ? {
      children: supplementPath(e.children)
    } : {}
  }))
}

export const menuHeader = supplementPath([
  { path: '/index', title: '首页', icon: 'home' }
])

export const menuAside = supplementPath([
  { path: '/index', title: '首页', icon: 'home' },
  {
    title: '部门考核',
    icon: 'folder-o',
    children: [
      { path: '/examinelist', title: '部门考核列表' },
      { path: '/templatelist', title: '部门考核模板列表' }
    ]
  }, {
    title: '考核设置',
    icon: 'folder-o',
    children: [
      { path: '/assessItem', title: '考核项' },
      { path: '/assessStandard', title: '考核指标' },
      { path: '/assesstype', title: '考核种类' }
      // { path: '/addItem', title: '添加考核项' }
    ]
  },
  {
    title: '考核展示',
    icon: 'folder-o',
    children: [
      { path: '/deptdisplay', title: '部门考核排名展示' }
    ]
  },
  {
    title: '个人信息',
    icon: 'folder-o',
    children: [
      { path: '/pendingTrial', title: '审核信息' },
      { path: '/toBeAssessed', title: '考核信息' }
    ]
  },
  {
    title: '系统设置',
    icon: 'folder-o',
    children: [
      { path: '/deptmanager', title: '部门管理' },
      { path: '/user', title: '用户管理' }
    ]
  },
  {
    title: '公司考核',
    icon: 'folder-o',
    children: [
      { path: '/template', title: '考核模板' },
      { path: '/inspectlist', title: '考核列表' }
    ]
  },
  {
    title: '日考核',
    icon: 'folder-o',
    children: [
      { path: '/addassess', title: '添加日考核' },
      { path: '/detail', title: '日考核详情' },
      { path: '/summary', title: '个人日考核汇总' },
      { path: '/batchreview', title: '批量审核' }
    ]
  }

])
